/**
 *
 */
import Util;
import OpenApi;

import EndpointUtil;

extends OpenApi;

init(config: OpenApi.Config){
  super(config);
  @endpointRule = 'central';
  
  checkConfig(config);
  @endpoint = getEndpoint('yundun-dbaudit', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }

  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}
model ClearInstanceStorageRequest {
  instanceId?: string(name='InstanceId'),
  regionId?: string(name='RegionId'),
  storageSpace?: string(name='StorageSpace'),
  storageCategory?: string(name='StorageCategory'),
}

model ClearInstanceStorageResponseBody = {
  requestId?: string(name='RequestId'),
}

model ClearInstanceStorageResponse = {
  headers: map[string]string(name='headers'),
  body: ClearInstanceStorageResponseBody(name='body'),
}

async function clearInstanceStorageWithOptions(request: ClearInstanceStorageRequest, runtime: Util.RuntimeOptions): ClearInstanceStorageResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('ClearInstanceStorage', '2021-04-16', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function clearInstanceStorage(request: ClearInstanceStorageRequest): ClearInstanceStorageResponse {
  var runtime = new Util.RuntimeOptions{};
  return clearInstanceStorageWithOptions(request, runtime);
}

model CreateInstanceConnectionRequest {
  instanceId?: string(name='InstanceId'),
  regionId?: string(name='RegionId'),
  vpcId?: string(name='VpcId'),
  bandwidth?: int32(name='Bandwidth'),
  vswitchIds?: [ string ](name='VswitchIds'),
  securityGroupIds?: [ string ](name='SecurityGroupIds'),
}

model CreateInstanceConnectionResponseBody = {
  requestId?: string(name='RequestId'),
}

model CreateInstanceConnectionResponse = {
  headers: map[string]string(name='headers'),
  body: CreateInstanceConnectionResponseBody(name='body'),
}

async function createInstanceConnectionWithOptions(request: CreateInstanceConnectionRequest, runtime: Util.RuntimeOptions): CreateInstanceConnectionResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('CreateInstanceConnection', '2021-04-16', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function createInstanceConnection(request: CreateInstanceConnectionRequest): CreateInstanceConnectionResponse {
  var runtime = new Util.RuntimeOptions{};
  return createInstanceConnectionWithOptions(request, runtime);
}

model DeleteInstanceConnectionRequest {
  instanceId?: string(name='InstanceId'),
  regionId?: string(name='RegionId'),
  vpcId?: string(name='VpcId'),
}

model DeleteInstanceConnectionResponseBody = {
  requestId?: string(name='RequestId'),
}

model DeleteInstanceConnectionResponse = {
  headers: map[string]string(name='headers'),
  body: DeleteInstanceConnectionResponseBody(name='body'),
}

async function deleteInstanceConnectionWithOptions(request: DeleteInstanceConnectionRequest, runtime: Util.RuntimeOptions): DeleteInstanceConnectionResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('DeleteInstanceConnection', '2021-04-16', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function deleteInstanceConnection(request: DeleteInstanceConnectionRequest): DeleteInstanceConnectionResponse {
  var runtime = new Util.RuntimeOptions{};
  return deleteInstanceConnectionWithOptions(request, runtime);
}

model DescribeInstanceAttributeRequest {
  instanceId?: string(name='InstanceId'),
  regionId?: string(name='RegionId'),
}

model DescribeInstanceAttributeResponseBody = {
  requestId?: string(name='RequestId'),
  instanceAttribute?: {
    instancePurchaseStorage?: long(name='InstancePurchaseStorage'),
    expireTime?: long(name='ExpireTime'),
    instanceTotalStorage?: long(name='InstanceTotalStorage'),
    imageVersion?: string(name='ImageVersion'),
    instanceId?: string(name='InstanceId'),
    instanceConnectionQuota?: int32(name='InstanceConnectionQuota'),
    regionId?: string(name='RegionId'),
    instanceDatabaseQuota?: long(name='InstanceDatabaseQuota'),
    startTime?: long(name='StartTime'),
    seriesCode?: string(name='SeriesCode'),
    description?: string(name='Description'),
    instanceStatus?: string(name='InstanceStatus'),
    licenseCode?: string(name='LicenseCode'),
    instanceConnectionMaxBandwidth?: int32(name='InstanceConnectionMaxBandwidth'),
    instanceConnections?: [ 
      {
        vpcId?: string(name='VpcId'),
        instanceConnectionBandwidth?: int32(name='InstanceConnectionBandwidth'),
        instanceConnectionDomain?: string(name='InstanceConnectionDomain'),
        securityGroupIds?: [ string ](name='SecurityGroupIds'),
        vswitchIds?: [ string ](name='VswitchIds'),
      }
    ](name='InstanceConnections'),
  }(name='InstanceAttribute'),
}

model DescribeInstanceAttributeResponse = {
  headers: map[string]string(name='headers'),
  body: DescribeInstanceAttributeResponseBody(name='body'),
}

async function describeInstanceAttributeWithOptions(request: DescribeInstanceAttributeRequest, runtime: Util.RuntimeOptions): DescribeInstanceAttributeResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('DescribeInstanceAttribute', '2021-04-16', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function describeInstanceAttribute(request: DescribeInstanceAttributeRequest): DescribeInstanceAttributeResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeInstanceAttributeWithOptions(request, runtime);
}

model DescribeInstancesRequest {
  pageSize?: int32(name='PageSize'),
  currentPage?: int32(name='CurrentPage'),
  regionId?: string(name='RegionId'),
  instanceStatus?: string(name='InstanceStatus'),
  resourceGroupId?: string(name='ResourceGroupId'),
  instanceId?: [ string ](name='InstanceId'),
  tag?: [ 
    {
      key?: string(name='Key'),
      value?: string(name='Value'),
    }
  ](name='Tag'),
}

model DescribeInstancesResponseBody = {
  totalCount?: long(name='TotalCount'),
  requestId?: string(name='RequestId'),
  instances?: [ 
    {
      instancePurchaseStorage?: long(name='InstancePurchaseStorage'),
      expireTime?: long(name='ExpireTime'),
      instanceTotalStorage?: long(name='InstanceTotalStorage'),
      imageVersion?: string(name='ImageVersion'),
      instanceId?: string(name='InstanceId'),
      instanceConnectionQuota?: int32(name='InstanceConnectionQuota'),
      regionId?: string(name='RegionId'),
      instanceDatabaseQuota?: long(name='InstanceDatabaseQuota'),
      startTime?: long(name='StartTime'),
      seriesCode?: string(name='SeriesCode'),
      description?: string(name='Description'),
      instanceStatus?: string(name='InstanceStatus'),
      licenseCode?: string(name='LicenseCode'),
      instanceConnectionMaxBandwidth?: int32(name='InstanceConnectionMaxBandwidth'),
    }
  ](name='Instances'),
}

model DescribeInstancesResponse = {
  headers: map[string]string(name='headers'),
  body: DescribeInstancesResponseBody(name='body'),
}

async function describeInstancesWithOptions(request: DescribeInstancesRequest, runtime: Util.RuntimeOptions): DescribeInstancesResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('DescribeInstances', '2021-04-16', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function describeInstances(request: DescribeInstancesRequest): DescribeInstancesResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeInstancesWithOptions(request, runtime);
}

model DescribeInstanceStorageRequest {
  instanceId?: string(name='InstanceId'),
  regionId?: string(name='RegionId'),
}

model DescribeInstanceStorageResponseBody = {
  requestId?: string(name='RequestId'),
  instanceStorages?: [ 
    {
      storageTime?: long(name='StorageTime'),
      storageCapacity?: long(name='StorageCapacity'),
      storageCategory?: string(name='StorageCategory'),
      storageSpace?: string(name='StorageSpace'),
      storageUsed?: long(name='StorageUsed'),
    }
  ](name='InstanceStorages'),
}

model DescribeInstanceStorageResponse = {
  headers: map[string]string(name='headers'),
  body: DescribeInstanceStorageResponseBody(name='body'),
}

async function describeInstanceStorageWithOptions(request: DescribeInstanceStorageRequest, runtime: Util.RuntimeOptions): DescribeInstanceStorageResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('DescribeInstanceStorage', '2021-04-16', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function describeInstanceStorage(request: DescribeInstanceStorageRequest): DescribeInstanceStorageResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeInstanceStorageWithOptions(request, runtime);
}

model DescribeRegionsRequest {
  acceptLanguage?: string(name='AcceptLanguage'),
  regionId?: string(name='RegionId'),
}

model DescribeRegionsResponseBody = {
  requestId?: string(name='RequestId'),
  regions?: [ 
    {
      regionEndpoint?: string(name='RegionEndpoint'),
      localName?: string(name='LocalName'),
      regionId?: string(name='RegionId'),
    }
  ](name='Regions'),
}

model DescribeRegionsResponse = {
  headers: map[string]string(name='headers'),
  body: DescribeRegionsResponseBody(name='body'),
}

async function describeRegionsWithOptions(request: DescribeRegionsRequest, runtime: Util.RuntimeOptions): DescribeRegionsResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('DescribeRegions', '2021-04-16', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function describeRegions(request: DescribeRegionsRequest): DescribeRegionsResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeRegionsWithOptions(request, runtime);
}

model ListTagKeysRequest {
  regionId?: string(name='RegionId'),
  resourceType?: string(name='ResourceType'),
  pageSize?: int32(name='PageSize'),
  currentPage?: int32(name='CurrentPage'),
}

model ListTagKeysResponseBody = {
  currentPage?: int32(name='CurrentPage'),
  requestId?: string(name='RequestId'),
  pageSize?: int32(name='PageSize'),
  totalCount?: int32(name='TotalCount'),
  tagKeys?: [ 
    {
      tagCount?: int32(name='TagCount'),
      tagKey?: string(name='TagKey'),
    }
  ](name='TagKeys'),
}

model ListTagKeysResponse = {
  headers: map[string]string(name='headers'),
  body: ListTagKeysResponseBody(name='body'),
}

async function listTagKeysWithOptions(request: ListTagKeysRequest, runtime: Util.RuntimeOptions): ListTagKeysResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('ListTagKeys', '2021-04-16', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function listTagKeys(request: ListTagKeysRequest): ListTagKeysResponse {
  var runtime = new Util.RuntimeOptions{};
  return listTagKeysWithOptions(request, runtime);
}

model ListTagResourcesRequest {
  regionId?: string(name='RegionId'),
  resourceType?: string(name='ResourceType'),
  nextToken?: string(name='NextToken'),
  resourceId?: [ string ](name='ResourceId'),
  tag?: [ 
    {
      key?: string(name='Key'),
      value?: string(name='Value'),
    }
  ](name='Tag'),
}

model ListTagResourcesResponseBody = {
  nextToken?: string(name='NextToken'),
  requestId?: string(name='RequestId'),
  tagResources?: [ 
    {
      tagValue?: string(name='TagValue'),
      resourceType?: string(name='ResourceType'),
      resourceId?: string(name='ResourceId'),
      tagKey?: string(name='TagKey'),
    }
  ](name='TagResources'),
}

model ListTagResourcesResponse = {
  headers: map[string]string(name='headers'),
  body: ListTagResourcesResponseBody(name='body'),
}

async function listTagResourcesWithOptions(request: ListTagResourcesRequest, runtime: Util.RuntimeOptions): ListTagResourcesResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('ListTagResources', '2021-04-16', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function listTagResources(request: ListTagResourcesRequest): ListTagResourcesResponse {
  var runtime = new Util.RuntimeOptions{};
  return listTagResourcesWithOptions(request, runtime);
}

model ModifyInstanceAttributeRequest {
  instanceId?: string(name='InstanceId'),
  description?: string(name='Description'),
  regionId?: string(name='RegionId'),
}

model ModifyInstanceAttributeResponseBody = {
  requestId?: string(name='RequestId'),
}

model ModifyInstanceAttributeResponse = {
  headers: map[string]string(name='headers'),
  body: ModifyInstanceAttributeResponseBody(name='body'),
}

async function modifyInstanceAttributeWithOptions(request: ModifyInstanceAttributeRequest, runtime: Util.RuntimeOptions): ModifyInstanceAttributeResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('ModifyInstanceAttribute', '2021-04-16', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function modifyInstanceAttribute(request: ModifyInstanceAttributeRequest): ModifyInstanceAttributeResponse {
  var runtime = new Util.RuntimeOptions{};
  return modifyInstanceAttributeWithOptions(request, runtime);
}

model ModifyInstanceStorageRequest {
  instanceId?: string(name='InstanceId'),
  regionId?: string(name='RegionId'),
  storageSpace?: string(name='StorageSpace'),
  storageCategory?: string(name='StorageCategory'),
  storageTime?: int32(name='StorageTime'),
}

model ModifyInstanceStorageResponseBody = {
  requestId?: string(name='RequestId'),
}

model ModifyInstanceStorageResponse = {
  headers: map[string]string(name='headers'),
  body: ModifyInstanceStorageResponseBody(name='body'),
}

async function modifyInstanceStorageWithOptions(request: ModifyInstanceStorageRequest, runtime: Util.RuntimeOptions): ModifyInstanceStorageResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('ModifyInstanceStorage', '2021-04-16', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function modifyInstanceStorage(request: ModifyInstanceStorageRequest): ModifyInstanceStorageResponse {
  var runtime = new Util.RuntimeOptions{};
  return modifyInstanceStorageWithOptions(request, runtime);
}

model MoveResourceGroupRequest {
  resourceId?: string(name='ResourceId'),
  resourceGroupId?: string(name='ResourceGroupId'),
  resourceType?: string(name='ResourceType'),
  regionId?: string(name='RegionId'),
}

model MoveResourceGroupResponseBody = {
  requestId?: string(name='RequestId'),
}

model MoveResourceGroupResponse = {
  headers: map[string]string(name='headers'),
  body: MoveResourceGroupResponseBody(name='body'),
}

async function moveResourceGroupWithOptions(request: MoveResourceGroupRequest, runtime: Util.RuntimeOptions): MoveResourceGroupResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('MoveResourceGroup', '2021-04-16', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function moveResourceGroup(request: MoveResourceGroupRequest): MoveResourceGroupResponse {
  var runtime = new Util.RuntimeOptions{};
  return moveResourceGroupWithOptions(request, runtime);
}

model RefundInstanceRequest {
  instanceId?: string(name='InstanceId'),
  regionId?: string(name='RegionId'),
  serviceCode?: string(name='ServiceCode'),
}

model RefundInstanceResponseBody = {
  requestId?: string(name='RequestId'),
}

model RefundInstanceResponse = {
  headers: map[string]string(name='headers'),
  body: RefundInstanceResponseBody(name='body'),
}

async function refundInstanceWithOptions(request: RefundInstanceRequest, runtime: Util.RuntimeOptions): RefundInstanceResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('RefundInstance', '2021-04-16', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function refundInstance(request: RefundInstanceRequest): RefundInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  return refundInstanceWithOptions(request, runtime);
}

model TagResourcesRequest {
  regionId?: string(name='RegionId'),
  resourceType?: string(name='ResourceType'),
  resourceId?: [ string ](name='ResourceId'),
  tag?: [ 
    {
      key?: string(name='Key'),
      value?: string(name='Value'),
    }
  ](name='Tag'),
}

model TagResourcesResponseBody = {
  requestId?: string(name='RequestId'),
}

model TagResourcesResponse = {
  headers: map[string]string(name='headers'),
  body: TagResourcesResponseBody(name='body'),
}

async function tagResourcesWithOptions(request: TagResourcesRequest, runtime: Util.RuntimeOptions): TagResourcesResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('TagResources', '2021-04-16', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function tagResources(request: TagResourcesRequest): TagResourcesResponse {
  var runtime = new Util.RuntimeOptions{};
  return tagResourcesWithOptions(request, runtime);
}

model UntagResourcesRequest {
  regionId?: string(name='RegionId'),
  resourceType?: string(name='ResourceType'),
  all?: boolean(name='All'),
  resourceId?: [ string ](name='ResourceId'),
  tagKey?: [ string ](name='TagKey'),
}

model UntagResourcesResponseBody = {
  requestId?: string(name='RequestId'),
}

model UntagResourcesResponse = {
  headers: map[string]string(name='headers'),
  body: UntagResourcesResponseBody(name='body'),
}

async function untagResourcesWithOptions(request: UntagResourcesRequest, runtime: Util.RuntimeOptions): UntagResourcesResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('UntagResources', '2021-04-16', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function untagResources(request: UntagResourcesRequest): UntagResourcesResponse {
  var runtime = new Util.RuntimeOptions{};
  return untagResourcesWithOptions(request, runtime);
}

model UpdateInstanceConnectionRequest {
  instanceId?: string(name='InstanceId'),
  regionId?: string(name='RegionId'),
  vpcId?: string(name='VpcId'),
  bandwidth?: int32(name='Bandwidth'),
  vswitchIds?: [ string ](name='VswitchIds'),
  securityGroupIds?: [ string ](name='SecurityGroupIds'),
}

model UpdateInstanceConnectionResponseBody = {
  requestId?: string(name='RequestId'),
}

model UpdateInstanceConnectionResponse = {
  headers: map[string]string(name='headers'),
  body: UpdateInstanceConnectionResponseBody(name='body'),
}

async function updateInstanceConnectionWithOptions(request: UpdateInstanceConnectionRequest, runtime: Util.RuntimeOptions): UpdateInstanceConnectionResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('UpdateInstanceConnection', '2021-04-16', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function updateInstanceConnection(request: UpdateInstanceConnectionRequest): UpdateInstanceConnectionResponse {
  var runtime = new Util.RuntimeOptions{};
  return updateInstanceConnectionWithOptions(request, runtime);
}

